package com.sync.discruptor;

import com.lmax.disruptor.EventTranslatorOneArg;
import com.lmax.disruptor.RingBuffer;
import com.sync.mutiParse.Block;

/**
 * post-3.0 the preferred approach for publishing messages is via the Event
 * Publisher/Event Translator portion of the API. E.g.
 * 
 * @author harry
 *
 */
public class LongEventProducerWithTranslator {
	private final RingBuffer<LongEvent> ringBuffer;

	public LongEventProducerWithTranslator(RingBuffer<LongEvent> ringBuffer) {
		this.ringBuffer = ringBuffer;
	}

	private static final EventTranslatorOneArg<LongEvent, Block> TRANSLATOR = new EventTranslatorOneArg<LongEvent, Block>() {
		public void translateTo(LongEvent event, long sequence, Block bb) {
			event.set(bb);
		}
	};

	public void product(Block bb) {
		ringBuffer.publishEvent(TRANSLATOR, bb);
	}
}